package com20230214.xiti;

import java.util.Random;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) {



        Random rand = new Random();
        int b = rand.nextInt(11) + 70;
        System.out.println(b);
        int x = -1;
        while (x == -1){
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入要猜的数字：");
            int a = sc.nextInt();
            x = compare(a,b);

        }








    }

    static int compare(int num1,int num2){


        if (num1 > num2){
            System.out.println("大了，请继续猜");
            return -1;
        }else if(num1 < num2){
            System.out.println("小了，请继续猜");
            return -1;

        }else{

            System.out.println("恭喜你，猜中了！");
            return 1;
        }

    }
}
